package me.sunpeng.java3;

/**
 * @author sp
 * @create 2022-06-16
 */

public class Demo01GenericClass {
    public static void main(String[] args) {
        //创建GenericClass对象，泛型使用Integer类型。
        GenericClass<Integer> gc = new GenericClass<>();
        gc.setName(1);
        System.out.println(gc.getName());


        GenericClass<?> gc1 = gc;
        Object name = gc1.getName();
        Number name1 = gc1.getName();

        GenericClass<Integer> gc2 = gc;
        Integer name2 = gc2.getName();
        Number name3 = gc2.getName();

    }
}

class GenericClass<E extends Number> {
    private E name;

    public E getName() {
        return name;
    }

    public void setName(E name) {
        this.name = name;
    }
}